
public class Plane extends Geometry {
	public Vector3 normal;
	public double d;
	public Vector3 position;
	
	public Plane(Vector3 n, double distance)
	{
		normal = n;
		d = distance;
		position = normal.mul(d);
	}
	
	public IntersectResult intersect(Ray3 ray)
	{
		double a = ray.direction.dot(normal);
		if(a >= 0)
		{
			return new IntersectResult();
		}
		
		double b = normal.dot(ray.origin.sub(position));
		IntersectResult result = new IntersectResult();
		result.geometry = this;
		result.distance = -b / a;
		result.position = ray.getPoint(result.distance);
		result.normal = this.normal;
		return result;
	}
}
